// author:zandaoguang
import Vue from 'vue'
import Router from 'vue-router'
// in development env not use Lazy Loading,because Lazy Loading too many pages will cause webpack hot update too slow.so only in production use Lazy Loading
/* layout */
import Layout from '../views/layout/Layout'

const _import = require('./_import_' + process.env.NODE_ENV)
Vue.use(Router)

// 所有权限通用路由表
// 如首页和登陆页和一些不用权限的公用页面
export const constantRouterMap = [
  {path: '/login', component: _import('login/index'), hidden: true},
  {path: '/404', component: _import('404'), hidden: true},
  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    name: '首页',
    hidden: true,
    children: [{
      path: 'dashboard', component: _import('dashboard/index')
    }]
  }
]

// 实例化vue的时候只挂载constantRouter
export default new Router({
  // mode: 'history', //后端支持可开
  scrollBehavior: () => ({y: 0}),
  routes: constantRouterMap
})


//异步挂载的路由
//动态需要根据权限加载的路由表 

//这里我们根据 vue-router官方推荐 的方法通过meta标签来标示改页面能访问的权限有哪些。如meta: { role: ['admin','super_editor'] }表示该页面只有admin和超级编辑才能有资格进入。
export const asyncRouterMap = [
  {
    path: '/alarm',
    component: Layout,
    redirect: '/alarm/alarm',
    children: [
      {
        path: 'alarm',
        name: '告警系统',
        component: _import('alarm/alarm'),
        meta: {title: '告警系统', icon: 'tree'},
        menu: 'alarm'
      },
    ]
  },

  {
    path: '/deeplearning',
    component: Layout,
    redirect: '/deeplearning/lstm',
    name: 'deeplearning',
    meta: {title: '轨道预测模型', icon: 'tree'},
    children: [
      {
        path: '/deeplearning/lstm', name: '', component: _import('deeplearning/lstm'), menu: 'deepleaning',
        children: [
          {
          path: 'lstm',
          name: 'TLE预报模型',
          component: _import('deeplearning/lstm'),
          meta: {title: 'TLE预报模型', icon: 'table'},
          menu: 'deeplearning'
          }
        ]
      },

      {
        path: '/deeplearning/prediction', name: '', component: _import('deeplearning/prediction'), menu: 'deepleaning',
        children: [
          {
          path: 'prediction',
          name: '速度位置预报模型',
          component: _import('deeplearning/prediction'),
          meta: {title: '速度位置预报模型', icon: 'table'},
          menu: 'deeplearning'
          }
        ]
      },
    ]
  },

  {
    path: '/collision',
    component: Layout,
    redirect: '/deeplearning/collision',
    children: [
      {
        path: 'lstm',
        name: '碰撞模型',
        component: _import('deeplearning/collision'),
        meta: {title: '碰撞模型', icon: 'tree'},
        menu: 'deeplearning'
      },
    ]
  },

  {
    path: '/upload',
    component: Layout,
    redirect: '/upload/tle',
    children: [
      {
        path: 'tle',
        name: '数据上传',
        component: _import('upload/tle_load'),
        meta: {title: '数据上传', icon: 'tree'},
        menu: 'upload'
      },
    ]
  },

  {
    path: '/satellite',
    component: Layout,
    redirect: '/satellite/satellite',
    name: 'satellite',
    meta: {title: '数据统计', icon: 'tree'},
    children: [
      {
        path: 'satellite', name: '卫星数据', component: _import('satellite/satellite'), meta: {title: '卫星数据', icon: 'table'}, menu: 'satellite',

      },

      {
        path: 'tle', name: 'TLE数据', component: _import('satellite/tle'), meta: {title: 'TLE数据', icon: 'table'}, menu: 'satellite',
      },
    ]
  },
  
  // {
  //   path: '/test',
  //   component: Layout,
  //   redirect: '/test/test',
  //   children: [
  //     {
  //       path: 'test',
  //       name: '测试页面',
  //       component: _import('test/test'),
  //       meta: {title: '测试页面', icon: 'tree'},
  //       menu: 'test'
  //     },
  //   ]
  // },

  {

    path: '/staff',
    component: Layout,
    redirect: '/staff/staff',
    name: 'staff',
    meta: {title: '系统管理', icon: 'tree'},
    children: [
      {
        path: '/staff/staff', name: '员工管理', component: _import('staff/staff'), menu: 'staff',
        children:[
          {
            path: 'test', name: '人员管理', component: _import('staff/test'), meta: {title: '人员管理', icon: 'table'}, menu: 'staff',
          },
        ]
      },
      {
        path: 'role', name: '权限管理', component: _import('user/role'), meta: {title: '权限管理', icon: 'table'}, menu: 'staff',
      },
    ]
  },

  {path: '*', redirect: '/404', hidden: true}
]
